<?php require_once 'source.php';?>
<?php require_once 'config.php';?>
<?php require_once 'dao/dao_db.php';?>
<?php require_once 'dao/dao_weekly_report.php';?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?php echo SYSTITLE?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="css/style.css" />
</head>
<body>
<div class="wrapper">
<?php require_once 'header.php';?>
<div id="layout">
	<div id="leftlay"><?php require_once 'leftnav.php';?></div>
	<div id="rightlay">
		<div class="columntitle"><?php echo WEEKLYREPORT?></div>
		<div class="columncontent">
		<?php 
			if($_SESSION['userid']!=''&&$_SESSION['level']==STUDENT){
		?>
			<div><a href="create_weekly_report.php"><?php echo CREATEREPORT?></a></div>
		<?php 
			}
		?>
			<div id="weeklyreport">
			<?php 	
				if($_SESSION['userid']!=''&&$_SESSION['level']==TEACHER){
					$result=get_report_list($_SESSION['userid']);
					mysql_close();
				}elseif($_SESSION['userid']!=''&&$_SESSION['level']==STUDENT){
					$result=get_report_list_s($_SESSION['userid']);
					mysql_close();
				}
				if(mysql_num_rows($result)!=0){				
			?>
				<table class="temptable">
				<tr>
					<th><?php echo REPORTTITLE?></th>
				<?php 
					if($_SESSION['level']==TEACHER){
				?>
					<th><?php echo USERNAME?></th>
				<?php 
					}
				?>
					<th><?php echo PUBLICDATE?></th>	
				</tr>
				<?php 
					while(($row=mysql_fetch_array($result))!=false){
						if($row['REPORTTITLE']!=''){
							$reportttitle=$row['REPORTTITLE'];
						}else{
							$reportttitle=$row['REPORTDATE'];
						}
				?>
					<tr>
						<td width="300"><a href="view_weekly_report.php?id=<?php echo $row['Id']?>"><?php echo $reportttitle?></a></td>
						<?php 
							if($_SESSION['level']==TEACHER){
						?>
						<td width="80"><?php echo $row['USERNAME']?></td>	
						<?php 
							}
						?>
						<td width="80"><?php echo $row['REPORTDATE']?></td>					
					</tr>
				<?php }?>
				</table>
			<?php 
				}else{
					echo NOREPORT;
				}
			?>
			</div>
		</div>
	</div>
</div>
</div>
</body>
</html>
